﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace AirForceCDCTests
{
    /// <summary>
    /// Interaction logic for Error.xaml
    /// </summary>
    public partial class ErrorWindow : Window
    {
        private string errorMessage;
        public bool NoError { get; set; }


        public ErrorWindow() : this("") {
        }

        public ErrorWindow(string errorMessage)
        {
            if (errorMessage.Trim() == "")
                this.NoError = true;

            this.errorMessage = errorMessage;
            InitializeComponent();
            errorBox.IsReadOnly = true;
            
            if (this.NoError == false)
                ShowErrorMessage();
        }

        public void SetErrorMessage(string message)
        {
            errorMessage = message;
            this.NoError = false;
            ShowErrorMessage();
        }


        private void ShowErrorMessage()
        {
            errorBox.Text = this.errorMessage + "\n";
            this.Show();
        }

        private void close_Click(object sender, RoutedEventArgs e)
        {
            this.Title = "Error";
            this.NoError = true;
            this.Hide();
        }

        private void close_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
                close_Click(sender, e);
        }
    }
}
